package com.zx.map.service;

import com.zx.map.dao.model.AgentInfo;
import com.zx.map.service.domain.AgentInfoDomain;
import com.zx.map.service.domain.agent.TransAgentDomain;
import com.zx.map.service.model.AgentInfoModel;
import com.zx.map.service.model.AgentSettleCardInfoModel;
import org.springframework.dao.DataAccessException;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA. User: Administrator Date: 14-3-1 Time: 上午11:06 To
 * change this template use File | Settings | File Templates.
 */
public interface AgentInfoService {

	/**
	 * 查找所有数据列表
	 * 
	 * @return
	 * @throws DataAccessException
	 */
	public List getAllList() throws DataAccessException;

	/**
	 * 根据单Key查找Model
	 * 
	 * @param key
	 * @return
	 * @throws DataAccessException
	 */
	public AgentInfoModel getModelByKey(String key) throws DataAccessException;


	/**
	 * 检验唯一性
	 * 
	 * @param model
	 * @return
	 * @throws DataAccessException
	 */
	public List checkSingle(AgentInfoModel model) throws DataAccessException;


	/**
	 * 新增并返回主键
	 * 
	 * @param model
	 * @return
	 * @throws DataAccessException
	 */
	public String editAgentInfo(AgentSettleCardInfoModel model, AgentInfoModel curAgentInfoModel)
			throws IOException, Exception;

	/**
	 * 分页查询
	 * @param domain
	 * @return
	 * @throws DataAccessException
	 */
	public Map getPageByDomain(AgentInfoModel curAgentInfoModel, AgentInfoDomain domain)
			throws DataAccessException;

	/**
	 * 根据登录名查找对应的代理商
	 * @param sysAccount
	 * @return
	 * @throws DataAccessException
	 */
	public AgentInfoModel getAgentInfoModelBySysAccount(String sysAccount)
			throws DataAccessException;

	/**
	 * 根据 bsid查询代理商信息
	 * @return
	 */
	public List<AgentInfo> queryAgentInfoByBsid(String bsid);

	public List<AgentInfo> queryAgentInfoByIdList(List<String> agentIds);

	Map<String,Object> updateAgentInfo(AgentInfoModel agentInfoModel, AgentInfoModel curAgentInfoModel);

	Map<String,Object> saveAgentInfo(AgentInfoModel agentInfoModel, AgentInfoModel curAgentInfoModel);

	Map<String,Object> saveOrUpdateAgentInfo(AgentInfoModel agentInfoModel, AgentInfoModel curAgentInfoModel);

	/**
	 * 获取本下、下级代理商
	 * hasCur是否包括本机构
	 * isDeep 纵深
	 * @return
	 * @throws DataAccessException
	 */
	List<String> queryDownAgentIdList(AgentInfoModel curAgentInfoModel);

	/**
	 * 带条件查询 下级代理商id
	 * @param curAgentInfoModel
	 * @param searchAgentInfoModel
	 * @return
	 */
	List<String> queryDownAgentIdList(AgentInfoModel curAgentInfoModel,AgentInfoModel searchAgentInfoModel);

	// * 获取本下、下级代理商id   查询深度根据当前用户角色判断
	List<AgentInfoModel> queryDownAgentInfoList(AgentInfoModel curAgentInfoModel);

	/**
	 * 带条件查询 下级代理商id
	 * @param curAgentInfoModel
	 * @param searchAgentInfoModel
	 * @return
	 */
	List<AgentInfoModel> queryDownAgentInfoList(AgentInfoModel curAgentInfoModel,AgentInfoModel searchAgentInfoModel);

	/**
	 * 更改从属关系
	 * @param fromBsid
	 * @param toBsid
	 * @return
	 */
	int updateAgentBelong(String fromBsid,String toBsid);

	/**
	 * 根据model  查询符合条件的代理
	 * @param model
	 * @return
	 */
	List<AgentInfoModel> queryAgentInfoJustByModel(AgentInfoModel model);

	/**
	 * 意愿代理分页查询
	 * @param domain
	 * @return
	 */
	public Map getWillAgentByDomain(AgentInfoDomain domain) throws DataAccessException;

	/**
	 * 转让代理
	 * @param curAgentInfoModel
	 * @param transAgentDomain
	 * @return
	 */
	Map<String,Object> transAgent(AgentInfoModel curAgentInfoModel, TransAgentDomain transAgentDomain);

	/**
	 * 关闭代理
	 * @param agentInfoModel
	 * @param curAgentInfoModel
	 * @return
	 */
	Map<String,Object> closeAgent(AgentInfoModel agentInfoModel, AgentInfoModel curAgentInfoModel);
}
